package com.compoundsystem.compound.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.compoundsystem.compound.pojo.Compound;
import com.compoundsystem.compound.service.CompoundService;
import com.compoundsystem.dto.CompoundQueryDto;
import com.compoundsystem.dto.UserQueryDto;
import com.compoundsystem.mapper.CompoundMapper;
import com.compoundsystem.user.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CompoundServiceImpl implements CompoundService {

    @Autowired
    CompoundMapper compoundMapper;

    //分页查询
    public IPage<Compound> selectCompoundPage(CompoundQueryDto compoundQueryDto) {
        Page<Compound> page = new Page<>(compoundQueryDto.getPageNo(),compoundQueryDto.getPageSize());
        return compoundMapper.selectCompoundPage(page,compoundQueryDto.getKeyword());
    }

    @Override
    public Integer addCompound(Compound compound) {
        return compoundMapper.insert(compound);
    }

    @Override
    public Integer updateCompound(Compound compound) {
        return compoundMapper.updateById(compound);
    }

    @Override
    public Integer deleteCompound(Integer id) {
        return compoundMapper.deleteById(id);
    }

    @Override
    public void batchDelete(List<Integer> ids) {
        compoundMapper.deleteBatchIds(ids);
    }

    @Override
    public Compound findSelect(Integer id) {
        return compoundMapper.selectById(id);
    }






}
